Document OmegaConf.merge handling of MISSING values (#771)#1309
Conversation
`OmegaConf.merge` gives `MISSING` ("???") on the source side a "no value
to apply" semantic — a non-missing value on the target is never
overwritten by a missing value coming from a later config. This comes
up regularly in user discussions (omry#729, hydra#1729) but was not stated
in the docs.
Add a short doctest-backed subsection to `docs/source/usage.rst` next
to the `OmegaConf.merge()` walk-through showing both directions (source
MISSING is skipped; target MISSING is filled by a later concrete value)
and a one-line motivation for the behavior.
|
Hi @jbbqqf, thanks again for your help. Filing a PR before I have an idea of how i want to solve it is premature. Thanks. |
omry
left a comment
There was a problem hiding this comment.
Accepted: this documents real OmegaConf.merge behavior with MISSING values and is worth making explicit.
Summary
OmegaConf.mergetreatsMISSING("???") on the source side as "no value to apply" — a non-missing target value is never overwritten by a missing source value. This behavior has resurfaced repeatedly in user discussions (#729, hydra#1729) but was not stated in the docs. Add a short doctest-backed subsection next to the existingOmegaConf.merge()walk-through.Fixes #771.
Context
Issue #771 (filed by @Jasha10) flagged that the merge-vs-missing rule is part of the public contract but only discoverable by reading source. The two motivating discussions:
The behavior itself is unchanged; this PR only adds documentation.
Changes
docs/source/usage.rst— new "Missing values inmerge()" subsection under the existingOmegaConf.merge()heading. Contains a sphinx doctest exercising both orderings (merge(base, override)keeps the concrete value;merge(override, base)fills the missing one) and a one-line motivation for the behavior.news/771.docs— towncrier entry.Reproduce BEFORE/AFTER yourself (copy-paste)
What I ran locally
sphinx-build -b doctest docs/source /tmp/doctest_outon the branch: 409 tests, 18 failures + 1 setup failure.sphinx-build -b doctest docs/source /tmp/doctest_mainonorigin/main: 404 tests, 18 failures + 1 setup failure.The 5-test delta is exactly the size of the new doctest block (one
>>> from omegaconf...plus four>>>data lines plus two expected outputs). The failure count is unchanged: my added block contributes zero new failures and the 18 pre-existing failures are numpy/repr-formatting artifacts unrelated to this PR.Edge cases tested
merge({port: 80}, {port: "???"})merge({port: "???"}, {port: 80})Risk / blast radius
Documentation only. No code changed, no behavior changed. The only file in
omegaconf/is untouched; the only addition is one.rstsubsection plus a towncrier entry.Release note
PR drafted with assistance from Claude Code. The doctest snippet was verified manually against
origin/main(behavior is pre-existing, only the docs change). The reproducer block above was used during development; it is the same one a reviewer can paste verbatim.